
var _path = '/zpmng/';
//url:form add and edit jsp
var _formAddEditUrl="/admin123/coding/a2userSum/add_edit.jsp";
//url:form add action
var _formAddAction="/admin123/coding/a2userSum/a2userAjax_addData.action";
//url:form edit action
var _formEditAction="/admin123/coding/a2userSum/a2userAjax_editData.action";
//url:form remove action
var _formRemoveAction="/admin123/coding/a2userSum/a2userAjax_removeData.action";
//url:report
var _formReportAction="/admin123/coding/a2userSum/a2userSumAjax_download.action";





var _keyRandom='201710082026';
//上个页面通过右击列表 传过来的 id和row; ps:右击模板x列，看模板列列表，自动加载列数，要传模板id找表名
var _prePageListRow = '${paramValues.row[0]}';
_prePageListRow = decodeURI(_prePageListRow);
var _prePageListId = '${paramValues._id[0]}';

//template table foreign key
var _foreignKey = 'a2post_id';
var _primaryKey = 'id';

//add dialog width and height
var _width4AddDialog = '0';
var _height4AddDialog = '0';
if(_width4AddDialog == '' || _width4AddDialog == '0')_width4AddDialog=800;
if(_height4AddDialog == '' || _height4AddDialog == '0')_height4AddDialog=400;
//dialog style, 取代上面的方法
var _isdialog4AddDialog = '1';
var _style4AddDialog = 'width:800px;height:500px;';
if(_style4AddDialog == '')_style4AddDialog='width:800px;height:400px';


/*
	hidden fileds when option has changed
	选择optionId时，filedList是要隐藏的域
	结构如下 ：
	var hiddenFileds = [
		{"optionId":"11","filedList":[{"text":"foreignkey"},{"text":"tablenamesql"}]},
		{"optionId":"12","filedList":[{"text":"tablenamehistorysql"},{"text":"sqlsum"}]}
	];
*/
var hiddenFileds = []



/**
	页面datagrid控件显示列元素：datagrid.columns
*/
var datagrid_columns = [[{"field":"id","hidden":"true","width":100,"title":"ID"},
	{"field":"owUserType_Str","width":100,"title":"员工类型"},
	{"field":"normalTaskPlanSum","width":100,"title":"日常计划(记录数)"},
	{"field":"specialTaskPlanSum","width":100,"title":"专项计划(记录数)"},
	{"field":"illegalRegisterSum","width":100,"title":"违规登记(记录数)"},
	{"field":"registerDataSum","width":100,"title":"勤务登记(记录数)"},
	{"field":"commiteeRecordSum","width":130,"title":"社区工作记录(记录数)"},
]]


/**
页面datagrid控件显示列元素：datagrid.frozenColumns
*/
var datagrid_frozenColumns = []
var jarrTmp = [{"field":"name","width":100,"title":"姓名"}];
var jo = {
"formatter":function(value,rowData,rowIndex){
if(typeof(rowData.id) == 'undefined'){return '';};
var btn = '';
btn += '<a rowIndex=\"'+rowIndex+'\" class=\"button\" style=\"height:16px;\"  href=\"javascript:void(0)\">菜单<\/a>';
    return btn;
    },
    "field":"menuItem",
    "width":70,
    "title":"菜单列表",
    "align":"center",
    "hidden":false};
var jarr = [];
//jarr.push(jo);
$.each(jarrTmp,function(index,value){
jarr.push(jarrTmp[index]);
})
datagrid_frozenColumns.push(jarr);


    /**
页面datagrid控件显示列元素：datagrid.toolbarBtns
*/
var datagrid_toolbarBtns = [];
datagrid_toolbarBtns[datagrid_toolbarBtns.length] = {
   id:'toolbarReportBtnId',text:'报表下载',
   iconCls:'icon-save',
   handler:function(){
	   downloadReportV2();
   }
}


function downloadReportV2() {
	//定义一个form表单
	var myform = $("<form></form>");
	myform.attr('method','post')
	myform.attr('action',_path+_formReportAction);

	var owUserType = $("<input type='hidden' name='owUserType' />")
	var owUserTypeValue = $("#owUserType").combobox("getValue");
	if(owUserTypeValue!=""){
		owUserType.attr('value',owUserTypeValue);
		myform.append(owUserType);
	}

	var name = $("<input type='hidden' name='name' />")
	var nameValue = $("#name").textbox("getValue");
	if(nameValue!=""){
		name.attr('value',nameValue);
		myform.append(name);
	}

	var createdatesum_Start = $("<input type='hidden' name='createdatesum_Start' />")
	var createdatesum_StartValue = $("#createdatesum_Start").datebox("getValue");
	if(createdatesum_StartValue!=""){
		createdatesum_Start.attr('value',createdatesum_StartValue);
		myform.append(createdatesum_Start);
	}

	var createdatesum_End = $("<input type='hidden' name='createdatesum_End' />")
	var createdatesum_EndValue = $("#createdatesum_End").datebox("getValue");
	if(createdatesum_EndValue!=""){
		createdatesum_End.attr('value',createdatesum_EndValue);
		myform.append(createdatesum_End);
	}


	myform.appendTo('body').submit();
};


/**
datagrid ，后面在condition.js中init了
*/
var datagrid={
	datagridId:"list",
	datagridUrl:"a2userSumAjax_queryListBySearch.action",
	datagridObj:{
		/*title:"查询列表",*/
		nowrap:true,
		autoRowHeight:false,
		fit:true,
		columns:datagrid_columns,//datasoure in data.js
		frozenColumns:datagrid_frozenColumns,
		toolbar:datagrid_toolbarBtns,
		rownumbers:true,
		showFooter:true,
		onRowContextMenu:onRowContextMenu
	}
};


var isFirstLoadSuccess = true;
datagrid.datagridObj.onLoadSuccess=function(){
	$('#'+datagrid.datagridId).datagrid('loaded');
	$("#queryBtn_Filter").removeAttr("disabled");

	//根据防问权限控制toolbar button显示或隐藏
	if (isFirstLoadSuccess) {
		$('#toolbarReportBtnId').hide();
		authRequestUrl(_formReportAction,function(authResult){
			if(authResult){
				$('#toolbarReportBtnId').show();
			}
		});
		isFirstLoadSuccess = false;
	}

};



//添加右击菜单内容
var id;
var rowIndex;
function onRowContextMenu(e, rowIndex1, rowData){
	e.preventDefault();
};




/**
打开AddDialog时，加载默认值
*/
var _defaultValueJOStr = {}


/**
所有列备份一下，一会隐藏了，可以恢复
*/
var _columnDivArray = new Array();
_columnDivArray[_columnDivArray.length] = '#_ow_user_type_line';
_columnDivArray[_columnDivArray.length] = '#_loginname_line';
_columnDivArray[_columnDivArray.length] = '#_password_line';
_columnDivArray[_columnDivArray.length] = '#_app_loginname_line';
_columnDivArray[_columnDivArray.length] = '#_app_password_line';
_columnDivArray[_columnDivArray.length] = '#_a2post_id_line';
_columnDivArray[_columnDivArray.length] = '#_name_line';
_columnDivArray[_columnDivArray.length] = '#_job_number_line';
_columnDivArray[_columnDivArray.length] = '#_email_line';
_columnDivArray[_columnDivArray.length] = '#_idcardno_line';
_columnDivArray[_columnDivArray.length] = '#_sex_line';
_columnDivArray[_columnDivArray.length] = '#_telephone_line';
_columnDivArray[_columnDivArray.length] = '#_phone_line';


